#pragma once
#include <vector>
#include <functional>

class UIElement;
class UISlider;
class UICircularProgressBar;
class UIProgressBar;

#define ToUISlider(elem) static_cast<UISlider*>(elem)
#define ToUICircularProgressBar(elem) static_cast<UICircularProgressBar*>(elem)
#define ToUIProgressBar(elem) static_cast<UIProgressBar*>(elem)

// Dynamically casts IUIProgressElement to normal UIElement
#define ToUIElement(elem) dynamic_cast<UIElement*>(elem);

class IUIProgressElement
{
public:
	float Value = 50.0f;
	float Interval = 10.0f;
	float MinValue = 0.0f, MaxValue = 100.0f;

	// Returns the value at the nearest interval
	float GetRoundedValue();

	using progress_callback_function = std::function<void(IUIProgressElement*)>;

	// Adds a callback function for when the progress value changes
	void AddValueChangedEvent(progress_callback_function evt) { m_ProgressCallbacks.push_back(evt); }

protected:
	std::vector<progress_callback_function> m_ProgressCallbacks;
};
